package com.hanliy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hanliy.dao.StorageMapper;
import com.hanliy.entity.PicStorageEntity;
import com.hanliy.service.StorageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author hanyulin
 * @apiNote
 * @date 2021/12/3 10:22
 */
@Service
public class StorageServiceImpl implements StorageService {

    @Resource
    private StorageMapper storageMapper;

    @Override
    public void insert(PicStorageEntity picStorage) {
        storageMapper.insert(picStorage);
    }

    @Override
    public PicStorageEntity findByKey(String key) {
        QueryWrapper<PicStorageEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pic_key", key);
        return storageMapper.selectOne(queryWrapper);
    }

    @Override
    public void delete(String key) {
        QueryWrapper<PicStorageEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pic_key",key);
        storageMapper.delete(queryWrapper);
    }

    @Override
    public List<PicStorageEntity> page(Page page, String sort) {
        return storageMapper.page(page,sort);
    }
}
